import {axiosInstance, ServiceResult} from "../utils/axiosInstance";
import {PageReq, PageRes} from "../entity/PageRes";
import {QueryInput} from "../entity/QueryInput";

export type TokenParams = {
  token: string;
};
export type IdsParams = {
  ids: number[];
};

export type Authority = {
  authorityName: string;
  createdAt: string;
  defaultRouter: string;
  id: number;
  menuIds: number[];
  parentId: string;
  updatedAt: string;
};

const prefix = 'api/packet';
export const getSummary = async (params: string): Promise<ServiceResult<string>> => {
  const response = await axiosInstance.request<ServiceResult<string>>({
    method: 'GET',
    url: `${prefix}/summary`,
    data: params,
  });
  return response.data;
};
export const getDetail = async (params: string): Promise<ServiceResult<string>> => {
  const response = await axiosInstance.request<ServiceResult<string>>({
    method: 'GET',
    url: `${prefix}/detail`,
    data: params,
  });
  return response.data;
};
export const getHex = async (params: string): Promise<ServiceResult<string>> => {
  const response = await axiosInstance.request<ServiceResult<string>>({
    method: 'GET',
    url: `${prefix}/hex`,
    data: params,
  });
  return response.data;
};
export const downloadPcap = async (id: string) => {
  const response = await axiosInstance.request({
    method: 'GET',
    url: `${prefix}/downloadPcap/${id}`,
    responseType: 'blob',
  });
  return response;
};
export const query = async (params: QueryInput): Promise<ServiceResult<string>> => {
  const response = await axiosInstance.request<ServiceResult<string>>({
    method: 'GET',
    url: `${prefix}/query`,
    params,
  });
  return response.data;
};
